package com.yix.study.tec.entity;

public class Client {
    public static void main(String[] args) {
        ConcreteProduct1 concreteProduct1 = (ConcreteProduct1) SimpleFactory.makeProduct(0);
        concreteProduct1.show();
    }

    //抽象产品
    public interface  Product{

        void show();

    }

    //具体产品1
    static class ConcreteProduct1 implements Product{
        @Override
        public void show() {
            System.out.println("产品1");
        }
    }
    //具体产品2
    static class ConcreteProduct2 implements Product{
        @Override
        public void show() {
            System.out.println("产品2");
        }
    }

    final class Const{
        static final int PRODUCT_A = 0;
        static final int PRODUCT_B = 1;
        static final int PRODUCT_C = 2;
    }


    static class SimpleFactory{
        public static Product makeProduct(int kind){
            switch (kind){
                case Const.PRODUCT_A:
                    return new ConcreteProduct1();
                case Const.PRODUCT_B:
                    return new ConcreteProduct2();
            }
            return null;
        }
    }
}
